
import ClipboardJS from 'clipboard'
import Store from '../store'


export default (app) => {
    app.directive("copy", (el, binding, vNode) => {
        el.setAttribute('data-clipboard-text', binding.value)
        let clipboard = new ClipboardJS(el);
        clipboard.on('success', (e) => {
                $global.message.success('复制成功')
            });
            clipboard.on('error', (e) => {
                $global.message.success('复制失败')
        });
    });

    app.directive("power", (el, binding, vNode) => {
        let powerList = Store.state.control.linePowerList
        let hasPoser = powerList.some(i => i.perCode == binding.value)
        if (!hasPoser) {
            el.parentNode && el.parentNode.removeChild(el)
        }
    });
}
